#include <cctype>
#include <cstdio>
using namespace std;

const int N = 600005;
int n, m, tot, cnt;
int trie[N << 5][2], root[N], val[N << 5];

inline int read() {
	int x = 0;
	bool f = false;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-')
			f = true;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return f ? -x : x;
}

inline void insert(int x) {
	int l = root[cnt], r = root[++cnt] = ++tot;
	for (register int i = 23; ~i; --i) {
		bool c = (x >> i) & 1;
		trie[r][!c] = trie[l][!c];
		trie[r][c] = ++tot;
		l = trie[l][c], r = trie[r][c];
		val[r] = val[l] + 1;
	}
}

inline int query(int l, int r, int x) {
	int res = 0;
	l = root[l], r = root[r];
	for (register int i = 23; ~i; --i) {
		bool c = (x >> i) & 1;
		if (val[trie[r][!c]] > val[trie[l][!c]])
			res += (1 << i), c = !c;
		l = trie[l][c], r = trie[r][c];
	}
	return res;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef DEBUG
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef DEBUG
	freopen("PersistedTrie.in", "r", stdin);
	freopen("PersistedTrie.out", "w", stdout);
#endif
#endif

	n = read(), m = read();
	insert(0);
	int tmp = 0, sum = 0, l = 0, r = 0;
	for (register int i = 0; i < n; ++i) {
		tmp = read();
		insert((sum ^= tmp));
	}
	int op;
	for (register int i = 0; i < m; ++i) {
		while (!isalpha(op = getchar())) {}
		switch (op) {
			case 'A':
				tmp = read();
				insert((sum ^= tmp));
				break;
			case 'Q':
				l = read(), r = read(), tmp = read();
				printf("%d\n", query(l - 1, r, (sum ^ tmp)));
				break;
		}
	}
	return 0;
}